<!--  -->
<template>
  <div class="editable-cell">
    <div v-if="editable && yearDialogType == 'edit' && nullValue" class="editable-cell-input-wrapper">
      <a-input-number
        ref="input"
        v-model="value"
        @change="handleChange"
        :min="0.00"
        :precision="2"
        :step="0.01"
        @pressEnter="check"
        @blur="check"
      />
    </div>
    <div v-else class="editable-cell-text-wrapper" @click="edit">
       <!-- {{ value || (isDetails == 1 ? '' : '请输入') }} -->
      <template v-if="yearDialogType == 'edit' && nullValue" >
        {{ value || (isDetails == 1? '' : '请输入') }}
      </template>
      <template v-else>
        {{ value || ''}}
      </template>
      <!-- <a-icon type="edit" class="editable-cell-icon" @click="edit" /> -->
    </div>
  </div>
</template>

<script>
export default {
  name: 'EditableCell',
  props: {
    text: [String, Number],
    isDetails: [String, Number],
    yearDialogType: String,
    nullValue: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      value: this.text,
      editable: false
    }
  },

  components: {},

  computed: {},

  created() {},

  mounted() {},

  methods: {
    handleChange(e) {
      this.value = Number(e).toFixed(2)
    },
    check() {
      this.editable = false
      this.$emit('change', this.value)
    },
    edit() {
      this.editable = true
    }
  }
}
</script>
<style lang='less' scoped>
</style>